Skip to content

[rfw] Add an example of using JavaScript with RFW #9110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

moluopro
Copy link

@moluopro moluopro commented Apr 18, 2025

I have added an example using JavaScript with RFW. This new example essentially replicates the functionality of the previous wasm example. Since the wasm package has been marked as discontinued and can no longer run directly on certain platforms, I included this new example as a replacement.

The new example is compatible with all Flutter platforms.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

@moluopro
Copy link
Author

moluopro commented May 8, 2025

I believe the wasm case should be removed, as it often fails to run in the new version of Flutter. Since this is a significant change, I would like to get the reviewer's opinion. @stuartmorgan-g

@stuartmorgan-g
Copy link
Contributor

@moluopro Please do not comment in completely unrelated PRs to request reviews. The proper escalation path, as explained in our contributor documentation, is to contact the reviewer via Discord.

I would like to get the reviewer's opinion. @stuartmorgan-g

The reviewer is @Hixie, the code owner for this package, not me.

@moluopro
Copy link
Author

moluopro commented May 8, 2025

@moluopro Please do not comment in completely unrelated PRs to request reviews. The proper escalation path, as explained in our contributor documentation, is to contact the reviewer via Discord.

I would like to get the reviewer's opinion. @stuartmorgan-g

The reviewer is @Hixie, the code owner for this package, not me.

I’m really sorry! I saw in that PR that, since Hixie didn’t respond, he reached out to you, so I thought I could do the same. I’m not very familiar with this process, as this is my first time submitting a PR for this library. I apologize again for the inconvenience caused.

@Hixie
Copy link
Contributor

Hixie commented May 8, 2025

It's an interesting example, but I don't really understand the use case for using RFW with a JS backend. If you're using JS, why not just send HTML?

@moluopro
Copy link
Author

moluopro commented May 9, 2025

The main reason I want to submit this change is that the WASM example is not running. I believe it's important to ensure that the official examples work on all Flutter platforms.

Secondly, JavaScript is a popular language with many users, so I chose it as the case.

@Hixie
Copy link
Contributor

Hixie commented May 10, 2025

I think we should separate those two problems. Making the Wasm example work again would be good. But that's an entirely separate problem from using RFW from JS.

@moluopro
Copy link
Author

moluopro commented May 11, 2025

Yes, you're right. Based on what I mentioned earlier:

First, the wasm example is not working, so I think we should consider whether to remove it.

Second, the JS example provided works across all platforms, so I think we could consider adding it (of course, depending on your opinion).

Third, I’d like to know what you think we should do. So far, I’ve only seen the questions, and I’m not clear on your opinion.

By the way, I don’t think the JS example is bad. This isn’t a change to the rfw library itself; it’s simply an additional example. Also, JS is indeed a very popular language, making it a very suitable choice for an example.

@Hixie
Copy link
Contributor

Hixie commented May 11, 2025

As far as the Wasm example goes, if it doesn't work, we should fix it. Is there an issue filed about this problem?

As far as the JS example goes, I would need to better understand why someone would want to use RFW with JS on the browser. It seems like a really weird combination of technologies. When would you want to use RFW in this way?

@moluopro
Copy link
Author

The package that wasm depends on is no longer maintained, so I would like to use a popular programming language as an alternative. My idea is that simple.

As for the fix to the original case you mentioned, maybe you can continue maintaining the wasm package. Thank you for your response, I now understand that you have no intention of merging this PR. I will close it later.

image

@moluopro
Copy link
Author

Thank you again for your response!

@Hixie
Copy link
Contributor

Hixie commented May 11, 2025

I misunderstood something about this patch -- I thought this was just JS in the browser, but it's using a JS runtime accessed by FFI. I do think that could be interesting. We'd need to make sure the tests all pass.

(Sorry, I got confused by the discussion of Wasm and JS and misunderstood what the example did. I think this PR should be considered independent of the issues with Wasm.)

@moluopro
Copy link
Author

I tested the latest stable version of Flutter, and it runs on all six supported platforms. I’ve already mentioned this repeatedly in the conversation above.

image

@Hixie
Copy link
Contributor

Hixie commented May 11, 2025

Yes I get that now. Sorry for being slow.

Before we can land anything though we would need to make sure the tests pass. Currently four checks are failing.

@moluopro
Copy link
Author

This is my first time handling this kind of process, so it might take me a bit more time.

@moluopro
Copy link
Author

moluopro commented May 11, 2025

Two issues remain and I need your help:

  1. Since Flutter 3.29, Android projects use build.gradle.kts by default. Therefore, the testing system (e.g., script/tool/test/gradle_check_command_test.dart) needs to be updated accordingly. Maybe I should file an issue for this?
Validating android/build.gradle.
PathNotFoundException: Cannot open file, path = '/b/s/w/ir/x/w/packages/packages/rfw/example/javascript/android/build.gradle' (OS Error: No such file or directory, errno = 2)
  1. The newly added JS dependencies need to be added to the allowlist.
[0:00] Running for packages/rfw/example/javascript...
  The following unexpected non-local dependencies were found:
    jsf
  Please see https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#Dependencies
  for more information and next steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants